package logic

import (
	"context"
	"good_srv/good"
	"good_srv/internal/svc"
	"good_srv/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type ActiveShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewActiveShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ActiveShowLogic {
	return &ActiveShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 活动详情
func (l *ActiveShowLogic) ActiveShow(in *good.ActiveShowRequest) (*good.ActiveShowResponse, error) {
	// todo: add your logic here and delete this line
	var a models.Active
	models.DB.Where("id=?", in.Id).Find(&a)

	return &good.ActiveShowResponse{
		Name:      a.Name,
		Price:     float32(a.Price),
		Stock:     a.Stock,
		Process:   int64(a.Process),
		Countdown: a.Countdown,
		Status:    int64(a.Status),
	}, nil
}
